import type { TokenVO } from "@/utils/auth";
import { http } from "@/utils/http";
import type { Result } from "./common";
import type { UserInfoVo } from "@/api/models";

/** 登录 */
export const getLogin = (data?: object) => {
  return http.request<Result<TokenVO>>("post", "/auth/login", { data });
};

/** 刷新token */
export const refreshTokenApi = (data?: object) => {
  return http.request<Result<TokenVO>>("post", "/auth/refresh_token", {
    data
  });
};

export const getUserInfo = () => {
  return http.get<UserInfoVo>("/system/user/info");
};
// 获取公司人员详情/project/company/user/details
export const getCompanyUserdetails = (companyUserId: any) => {
  return http.request(
    "get",
    "/project/company/user/details?companyUserId=" + companyUserId
  );
};

export const getCompanyUser = () => {
  return http.request("get", "/project/company/user/admin/all-group-user");
};
// 获得公司部门
export const getCompanyGroup = () => {
  return http.request("get", "/project/company/user/groups");
};
// 获得部门的成员
export const getGroupUser = id => {
  return http.request("get", "/project/company/user/list?groupId=" + id);
};
//离职用户/project/company/user/admin/leave
export const deleteUser = (id: BigInt) => {
  return http.request(
    "delete",
    "/project/company/user/admin/leave?companyUserId=" + id
  );
};
//分配角色
export const editUserRole = data => {
  return http.request("put", "/project/company/user/admin/update-role", {
    data: data
  });
};
//修改个人信息/system/user/info
export const editUserInfo = data => {
  return http.request("put", "/system/user/info", { data: data });
};
//获取公司所有的用户/project/company/user/all-user
export const getAllUser = data => {
  return http.request("get", "/project/company/user/all-user", { data: data });
};
